package com.mxx.common.data.mongo;

import org.bson.Document;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update;
import org.springframework.data.mongodb.repository.MongoRepository;

import java.util.List;
import java.util.Optional;

/**
 * @Author itzgyw
 * @Date 2020-01-28
 * @Time 21:47
 * @Description:
 */
public interface CustomMongoDBRepository<T, ID> extends MongoRepository<T, ID> {
    boolean updateById(T entity);

    boolean updateById(Document update);

    Optional<T> findOne(Query query);

    Page<T> findPage(Query query, Pageable pageable);


    Page<T> findPage(Pageable pageable);

    List<T> findAll(Query query);


    long count(Query query);

    long delete(Query query);


    long updateMulti(Query query, Update update);

    Class<T> getDomainClass();
}
